package com.jiutong.meipenggang.http.present;

import android.content.Context;

import com.jiutong.meipenggang.common.Constants;
import com.jiutong.meipenggang.entity.TotalMoneyDetailBean;
import com.jiutong.meipenggang.http.model.interfaces.TotalMoneyDetailBiz;
import com.jiutong.meipenggang.http.model.requests.TotalMoneyDetailRequest;
import com.jiutong.meipenggang.http.subscribers.ProgressSubscriber;
import com.jiutong.meipenggang.http.subscribers.SubscriberOnNextListener;
import com.jiutong.meipenggang.utils.SpConfig;
import com.jiutong.meipenggang.utils.TimeUitl;

import java.util.HashMap;

/**
 * @author Veken
 * @date on 2017/12/29 11:21
 * @describe
 */

public class TotalMoneyDetailPresent {

    private TotalMoneyDetailRequest totalMoneyDetailRequest;
    private Context mContext;
    private TotalMoneyDetailBiz biz;

    public TotalMoneyDetailPresent(Context mContext, TotalMoneyDetailBiz biz) {
        this.mContext = mContext;
        this.biz = biz;
        totalMoneyDetailRequest = new TotalMoneyDetailRequest();
    }

    /**
     * 获取总资产详情
     */
    public void getTotalMoneyDetal() {

        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<TotalMoneyDetailBean>() {
            @Override
            public void onNext(TotalMoneyDetailBean o) {
                biz.onSuccess(o);
            }

            @Override
            public void onError(Throwable e) {
                biz.onError(e);
            }
        };
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("OPT", 23);
        hashMap.put("timestamp", TimeUitl.getDate());
        hashMap.put("id", SpConfig.getInstance().getString(Constants.ID));
        hashMap.put("token", SpConfig.getInstance().getString(Constants.TOKEN));
        hashMap.put("currPage", biz.getCurrentPage());
        hashMap.put("time", biz.getTime());
        totalMoneyDetailRequest.getTotalMoneyDetail(new ProgressSubscriber(onNextListener, mContext), hashMap);
    }
}
